﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

/* Generated with http://xmltocs.com/ */
namespace EDMXParserV1
{
    public class EntitySet
    {
        public String Name { get; set; }
        public String EntityType { get; set; }
        public String StoreType { get; set; }
        public String Schema { get; set; }
        public String DefiningQuery { get; set; }
        public String StoreName { get; set; }
        public String StoreSchema { get; set; }

        // Crossmapping fields.
        public EntityType EntityTypeLink { get; set; }

        public static EntitySet New(XmlNode Node)
        {
            EntitySet EntitySet = new EntitySet();
            foreach (XmlAttribute Attribute in Node.Attributes)
            {
                switch (Attribute.Name)
                {
                    case "Name":
                        EntitySet.Name = Attribute.Value;
                        break;
                    case "EntityType":
                        EntitySet.EntityType = Attribute.Value;
                        break;
                    case "store:Type":
                        EntitySet.StoreType = Attribute.Value;
                        break;
                    case "Schema":
                        EntitySet.Schema = Attribute.Value;
                        break;
                    case "store:Name":
                        EntitySet.StoreName = Attribute.Value;
                        break;
                    case "store:Schema":
                        EntitySet.StoreSchema = Attribute.Value;
                        break;
                    default:
                        Globals.AttributeSwitchCoder(Attribute);
                        break;
                }
            }

            foreach (XmlNode ChildNode in Node.ChildNodes)
            {
                switch (ChildNode.Name)
                {
                    case "DefiningQuery":
                        EntitySet.DefiningQuery = ChildNode.InnerText;
                        break;

                    default:
                        Globals.NodeSwitchCoder(ChildNode);
                        break;
                }
            }
            return EntitySet;
        }
    }
}
